cmake_minimum_required(VERSION 3.0)

project(ros1_protobuf_msg_bridge_test)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  rosbag
  std_msgs
  actionlib
  actionlib_msgs
  message_generation
)
generate_messages(
  DEPENDENCIES
  actionlib_msgs
)

# --------BEGIN 以下为使用protobuf所需的配置--------
# 请先安装ros1-protobuf-msg-bridge-***.deb
set(THIRD_LIBS_ROOT_DIR /opt/libs-x86_64-Linux)
list(APPEND CMAKE_MODULE_PATH ${THIRD_LIBS_ROOT_DIR}/cmake/modules)
find_package(Protobuf REQUIRED)

list(APPEND catkin_LIBRARIES "/opt/ros/melodic/lib/libros1_protobuf_msg_bridge.a")
list(APPEND catkin_LIBRARIES ${Protobuf_LIBRARYS})
list(APPEND catkin_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR})
# --------END 以上为使用protobuf所需的配置--------

# 发布订阅测试
add_executable(pub src/pub.cpp)
add_dependencies(pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_include_directories(pub PUBLIC ${catkin_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
target_link_libraries(pub ${catkin_LIBRARIES})

add_executable(sub src/sub.cpp)
add_dependencies(sub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_include_directories(sub PUBLIC ${catkin_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
target_link_libraries(sub ${catkin_LIBRARIES})


# serv测试
add_executable(serv_server src/serv_server.cpp)
add_dependencies(serv_server ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_include_directories(serv_server PUBLIC ${catkin_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
target_link_libraries(serv_server ${catkin_LIBRARIES})

add_executable(serv_client src/serv_client.cpp)
add_dependencies(serv_client ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_include_directories(serv_client PUBLIC ${catkin_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
target_link_libraries(serv_client ${catkin_LIBRARIES})


# action测试
add_executable(act_client src/act_client.cpp)
add_dependencies(act_client ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_include_directories(act_client PUBLIC ${catkin_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
target_link_libraries(act_client ${catkin_LIBRARIES})

add_executable(act_server src/act_server.cpp)
add_dependencies(act_server ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_include_directories(act_server PUBLIC ${catkin_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR})
target_link_libraries(act_server ${catkin_LIBRARIES})

